<?php
declare(strict_types=1);

namespace ServerApp\lib\server\model\swoole;

use ServerApp\lib\server\model\swoole\lib\SwooleTable;
use swoole_table;

/**
 * Class ConfTable
 * @package Tao\src\model
 */
class ConfTable
{
    const TYPE = 'type';
    const HOST = 'host';
    const WORKER_ID = 'worker_id';

    private function __construct()
    {
    }

    private static $instance = null;

    /**
     * @return SwooleTable
     */
    public static function getInstance(): swoole_table
    {
        if (self::$instance === null){
            self::$instance = new SwooleTable(
                128,
                [
                    self::TYPE=> [
                        swoole_table::TYPE_INT, 4
                    ],
                    self::HOST=> [
                        swoole_table::TYPE_STRING, 25
                    ],
                    self::WORKER_ID=> [
                        swoole_table::TYPE_INT, 4
                    ],
                ]
            );
        }
        return self::$instance;
    }
}